<template>
	<view class="more-item">
		<!-- 传递参数 -->
		<navigator :url="'/pages/classList/classList?id=' + obj._id+'&name='+ obj.name" class="box" v-if="!isMore">
			<image class="pic" :src="obj.picurl" mode="aspectFill"></image>
			<view class="mask">{{obj.name}}</view>
			<!-- 有时间的时候就显示，超过三个月不显示 -->
			<view class="test" v-if="formatTimeDifference(obj.updateTime)">{{formatTimeDifference(obj.updateTime)}}</view>
		</navigator>

		<navigator url="/pages/classify/classify" open-type="switchTab" class="box more" v-if="isMore">
			<image class="pic" src="/common/images/more.jpg" mode="aspectFill"></image>
			<view class="mask">
				<uni-icons type="more-filled" size="34" color="#fff"></uni-icons>
				<view class="text">更多</view>
			</view>
		</navigator>
	</view>
</template>

<script setup>
import {formatTimeDifference} from '/utils/common.js'
	defineProps({
		isMore: {
			type: Boolean,
			default: false
		},
		//接收index传来的数据
		obj:{
			type:Object,
			default(){
				return{
				name:'默认名称',
				picurl:'/common/images/classify1.jpg',
				updateTime:Date.now() -1000*60*60*5
			}
		}
		}
	})
</script>

<style lang="less" scoped>
	.more-item {

		.box {
			position: relative;
			height: 340rpx;
			overflow: hidden;
			border-radius: 10rpx;
			margin: 0;
			/* 清除外边距 */
			box-sizing: border-box;

			.pic {
				width: 100%;
				height: 100%;

			}

			.mask {
				font-size: 28rpx;
				color: aliceblue;
				height: 70rpx;
				width: 100%;
				display: flex;
				justify-content: center;
				align-items: center;
				position: absolute;
				font-weight: 600;
				left: 0;
				bottom: 0;
				background: rgba(0, 0, 0, 0.2);
				backdrop-filter: blur(20rpx);
			}

			.test {
				position: absolute;
				left: 0;
				top: 0;
				background-color: #ffaa7f;
				border-radius: 0 0 10rpx 0;
				padding: 10rpx;
			}
		}

		.box.more {
			.mask {
				width: 100%;
				height: 100%;
				flex-direction: column;


				.text {
					font-size: 28rpx;
				}
			}
		}
	}
</style>